package PolymorphismBlogDemo.LowerTransferDealUTF;

public class DealUTF {
    public static void main(String[] args) {
        Animal bird = new Bird();
        Animal fish = new Fish();
        bird.eat();
        fish.eat();
        if(bird instanceof Bird) {
            Bird Obird = (Bird)bird;
            Obird.fly();
        }
        if(fish instanceof Fish) {
            Fish Ofish = (Fish)fish;
            Ofish.swim();
        }
    }
}
class Animal {
    public void eat () {
        System.out.println("吃东西");
    }
}
class Bird extends Animal {
    @Override
    public void eat() {
        System.out.println("吃鸟粮");
    }
    public void fly() {
        System.out.println("正在飞");
    }
}
class Fish extends Animal {
    @Override
    public void eat() {
        System.out.println("吃鱼粮");
    }
    public void swim() {
        System.out.println("正在游");
    }
}